<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>信息编辑页</title>
    <link rel="icon" href="img/tubiao.png">
    <style type="text/css">
        * {
            padding: 0;
            margin: 0;
        }

        body {
            background: url('img/bj.jpg')no-repeat;
            background-size: 100% 100%;
            background-attachment: fixed;
            font-size: 30px;
        }

        #dcopy {
            width: 100%;
            height: 100px;
            /* background-color: #e3e2e2; */
            color: #9f9378;
            font-size: 16px;
        }
    </style>
</head>

<body>
    <div class="d1" style="text-align: center;line-height: 35px;margin-top: 135px;">
        设置信息修改
        <div id="all">
            <div class="a1">
                昵称&nbsp;&nbsp;&nbsp;：<input type="text" name="a11" class="ipt" id="nc">
            </div>
            <div class="a1">
                旧密码：<input type="text" name="a33" class="ipt" id="jm">
            </div>
            <div class="a1">
                新密码：<input type="text" name="a44" class="ipt" id="xm">
            </div>
            <div class="a1">
                出生&nbsp;&nbsp;&nbsp;：<input type="text" name="a55" class="ipt" id="cs">
            </div>
            <div class="a1">
                感言&nbsp;&nbsp;&nbsp;：<input type="text" name="a66" class="ipt" id="gy">
            </div>
            <div class="a1">
                段位&nbsp;&nbsp;&nbsp;：<input type="text" name="a77" class="ipt" id="dw">
            </div>
        </div>
        <button id="an1" style="width: 80px;height: 40px;">保存</button>
        <button id="an2" style="width: 80px;height: 40px;">取消</button>
    </div>
    <div id="dcopy">
        <br>
        <p align="center"> &copy; 版权由计算2201蒋杵峻归属，未经允许不得复制、镜像</p>
        <br>
        <p align="center">本网络游戏适合18+岁的用户使用；为了您的健康，请合理控制游戏时间。</p>
    </div>

    <script>
        searchid = function () {
            var id = "";
            var url = window.location.href;
            var start = url.indexOf('?');
            id = url.substring(start + 1, url.indexOf('id$'));
            return id;
        }
        var usename = searchid();
        usename = unescape(usename);
        function check() {
            var arr = [];
            arr = localStorage.getItem(usename).split(',')
            return arr;
        }
        var jiu = check();
        var bao = document.querySelector('#an1');
        var xiao = document.querySelector('#an2');
        xiao.onclick = function () {
            location.href = 'xxzy.html?' + searchid() + 'id$';
        }
        var nc = document.querySelector('#nc');
        var xm = document.querySelector('#xm');
        var cs = document.querySelector('#cs');
        var gy = document.querySelector('#gy');
        var dw = document.querySelector('#dw');
        bao.onclick = function () {
            if (right()) {
                if (nc.value.length > 0) {
                    jiu[2] = nc.value;
                }
                if (xm.value.length > 6) {
                    if (allow()) {
                        jiu[0] = xm.value;
                    } else {
                        alert('密码必须包含大小写字母以及数字');
                    }
                } else if (xm.value.length > 0) {
                    alert('密码至少7位');
                }
                if (cs.value.length > 0) {
                    jiu[3] = cs.value;
                }
                if (gy.value.length > 0) {
                    jiu[4] = gy.value;
                }
                if (dw.value.length > 0) {
                    jiu[5] = dw.value;
                }
                localStorage.setItem(usename, gai(JSON.stringify(jiu)));
                location.href = 'xxzy.html?' + searchid() + 'id$';
            } else {
                alert('旧密码不正确');
            }
        }
        right = function () {
            var q = document.querySelector('#jm');
            return q.value == jiu[0];
        }

        function allow() {
            var A=false;
            var a = false;
            var a1 = false;
            var str = xm.value;
            for (var i = 0; i < str.length; i++) {
                var t = str.charAt(i);
                if (t >= 'a' && t <= 'z') a = true;
                if (t >= 'A' && t <= 'Z') A = true;
                if (t >= 0 && t <= 9) a1 = true;
            }
            return a && A && a1;
        }

        gai = function (sj) {
            var ans = sj;
            ans = ans.replace('[', '');
            ans = ans.replace(']', '');
            ans = ans.replace(/"/g, '');
            return ans;
        }
    </script>
</body>

</html>